let zz = {
  watch: {
    "$store.state.daping.scencetype": {
      handler: function(n, o) {
        //清空数据
        this.destoryds();
        //加载数据
        switch (n) {
          case "nengxiao":
            this.nengxiao();
            break;
          case "gongre":
            this.gongre();
            break;
          default:
            break;
        }
      }
      // immediate: true,
    }
  },
  methods: {
    zhengzhou() {
      this.$store.state.daping.scencetype = "gongre";
    },
    
    destoryds() {
      let _this = this;

      //清理geojson数据     能效供热
      if (this.ds.length != 0) {
        for (let index1 = 0; index1 < this.ds.length; index1++) {
          for (
            let index = 0;
            index < this._viewer.dataSources.length;
            index++
          ) {
            if (this.ds[index1] == this._viewer.dataSources.get(index)._name) {
              this._viewer.dataSources.remove(
                this._viewer.dataSources.get(index)
              );
            }
          }
        }
      }

      //清理odlines
      
      _.forIn(this.odlinesarr, (v, k) => { 
        v.destroy();
      })


      //清理EarthSDK点
      let pinarr = this.pinarr;
      pinarr.map(item => {
        this._earth.sceneTree.root.children.map((eactpin, index) => {
          if (eactpin.ref == item) {
            this._earth.sceneTree.root.children.splice(index, 1);
          }
        });
      });

      // let pinarr = this.pinarr
      // let earthchild = _.cloneDeep(this._earth.sceneTree.root.children);
      // pinarr.map(item => {
      //   earthchild.map((eactpin,index) =>{
      //     if (eactpin.ref == item) {
      //       this._earth.sceneTree.root.children.splice(index, 1);
      //       // this._earth.sceneTree.$refs[item].destroy()
      //     }
      //   })
      // })

      //清理msgbox
      this.msgboxarr = [];

      this.ds = [];
    }
  }
};

export default zz